package online.hxstar.cloud.conmuser.stream.listenner;

import lombok.extern.slf4j.Slf4j;
import online.hxstar.cloud.conmuser.stream.bind.HelloBinding;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;

import java.util.Random;

/**
 * @author xinghu
 * @version 1.0
 * @date 2019/11/12 11:39 上午
 */
@EnableBinding(HelloBinding.class)
@Slf4j
public class HelloListener {


	private Random random = new Random();

	@StreamListener(target = HelloBinding.GREETING_INPUT)
	public void processHelloChannelGreeting(String message) {
		boolean res = random.nextBoolean();
		log.info(message + res);
		if (res) {
			throw new RuntimeException("滴答滴答滴答滴答`");
		}
	}
}
